home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac: Not for Sale
/
Another.not.for.sale (Australia).iso
/
fade into you
/
getting there
/
WWW
/
MacHTTP 1.3.1b16
/
password.cgi (text-only)
< prev
next >
Wrap
Text File
|
1994-09-16
|
2KB
|
31 lines
-- This script demonstrates how to invoke the authentication function in WWW clients.
-- Currently, only Mac Mosaic 2.0ax supports this capability.
-- This script should be compiled and saved as an application before running
on «event WWWΩsdoc» path_args ¬
given «class kfor»:http_search_args, «class post»:post_args, «class meth»:method, «class addr»:client_address, «class user»:username, «class pass»:password
set crlf to (ASCII character 13) & (ASCII character 10)
--this builds the normal HTTP header for regular access
set http_10_header to "HTTP/1.0 200 OK" & crlf & "Server: MacHTTP" & crlf & ¬
"MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf
--this builds a header that informs the client that a username and password is
--required to access the document.
set auth_header to "HTTP/1.0 401 Unauthorized" & crlf & "Server: MacHTTP" & crlf & ¬
"MIME-Version: 1.0" & crlf & "WWW-Authenticate: Basic realm=\"MacHTTP\"" & crlf & crlf
if username = password then -- a quick and dirty way to see if both are empty (most of the time)
return auth_header & "Too bad, you're not authorized unless you have a valid user ID and password"
else
return http_10_header & "You're Authorized! You sent: <br>path:" & path_args & ¬
"<br>search:" & http_search_args & ¬
"<br>post_args:" & post_args & ¬
"<br>method:" & method & ¬
"<br>address:" & client_address & ¬
"<br>user:" & username & ¬
"<br>password:" & password
end if
end «event WWWΩsdoc»